﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AcceptanceTest.PasswordSample
{
    public static class PasswordValidator
    {
        /// <summary>
        /// To be valid, a password must be from 6 to 12 characters long and include 
        /// at least one letter, 
        /// at least one digit, and 
        /// at least one punctuation character.
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public static bool IsValidPassword(string password)
        {
            if (string.IsNullOrEmpty(password)) return false;
            return Regex.IsMatch(password, @"(?=^.{6,12}$)(?=.*\d)(?=.*\W+)(?![.\n])(?=.*[A..Z,a..z]).*$");
        }
    }
}
